package fplaton.ui;

import fplaton.db.SQLiteJDBC;
import fplaton.helper.Validation.*;
import static fplaton.helper.Validation.isEmail;
import static fplaton.helper.Validation.isNullorEmpty;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.swing.JOptionPane;
import fplaton.ui.addteacher;

/**
 *
 * @author dastergon
 */
public class CentralForm extends javax.swing.JFrame {

    /**
     * Creates new form CentralForm
     */
    public CentralForm() {
        initComponents();
    }

    /**
     * This method is called from within the constructor to initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is always
     * regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jFrame1 = new javax.swing.JFrame();
        jPanel1 = new javax.swing.JPanel();
        nameLabel = new javax.swing.JLabel();
        nameField = new javax.swing.JTextField();
        fnameLabel = new javax.swing.JLabel();
        fnameField = new javax.swing.JTextField();
        mnameLabel = new javax.swing.JLabel();
        mnameField = new javax.swing.JTextField();
        birthdateLabel = new javax.swing.JLabel();
        birthdateField = new javax.swing.JTextField();
        phoneLabel = new javax.swing.JLabel();
        hphoneLabel = new javax.swing.JLabel();
        phoneField = new javax.swing.JTextField();
        hphoneField = new javax.swing.JTextField();
        addButton = new javax.swing.JButton();
        homeAddrLabel = new javax.swing.JLabel();
        homeAddrField = new javax.swing.JTextField();
        studentEmailLabel = new javax.swing.JLabel();
        studentEmailField = new javax.swing.JTextField();
        parentEmailLabel = new javax.swing.JLabel();
        parentEmailField = new javax.swing.JTextField();
        addStudentButton = new javax.swing.JButton();
        jSeparator = new javax.swing.JSeparator();
        jLabel1 = new javax.swing.JLabel();
        oikonomikaButton = new javax.swing.JButton();
        courseButton = new javax.swing.JButton();
        OpenInsertClassFormjButton = new javax.swing.JButton();
        viewStudentsButton = new javax.swing.JButton();
        addTeacherButton = new javax.swing.JButton();

        jFrame1.setTitle("Add a student");
        jFrame1.setBounds(new java.awt.Rectangle(200, 150, 0, 0));
        jFrame1.setMinimumSize(new java.awt.Dimension(300, 450));
        jFrame1.setResizable(false);

        nameLabel.setText("Όνομα:");

        nameField.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                nameFieldActionPerformed(evt);
            }
        });

        fnameLabel.setText("Πατρώνυμο:");

        mnameLabel.setText("Όνομα μητέρας:");

        birthdateLabel.setText("Ημ/νια γέννησης:");

        phoneLabel.setText("Τηλέφωνο:");

        hphoneLabel.setText("Τηλέφωνο(Σπίτι):");

        addButton.setText("Προσθήκη");
        addButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                addButtonActionPerformed(evt);
            }
        });

        homeAddrLabel.setText("Διεύθυνση:");

        studentEmailLabel.setText("Email μαθητή");

        parentEmailLabel.setText("Εmail γονέα");

        parentEmailField.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                parentEmailFieldActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
        jPanel1.setLayout(jPanel1Layout);
        jPanel1Layout.setHorizontalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(addButton)
                    .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                        .addGroup(jPanel1Layout.createSequentialGroup()
                            .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                                .addComponent(fnameLabel, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                                .addComponent(nameLabel, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                            .addGap(45, 45, 45)
                            .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                .addComponent(fnameField)
                                .addComponent(nameField)))
                        .addGroup(jPanel1Layout.createSequentialGroup()
                            .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
                                .addComponent(hphoneLabel, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                                .addComponent(mnameLabel, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                                .addComponent(phoneLabel, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                                .addComponent(birthdateLabel, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                            .addGap(14, 14, 14)
                            .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                .addComponent(phoneField, javax.swing.GroupLayout.DEFAULT_SIZE, 115, Short.MAX_VALUE)
                                .addComponent(birthdateField, javax.swing.GroupLayout.Alignment.TRAILING)
                                .addComponent(mnameField)
                                .addComponent(hphoneField)))
                        .addGroup(jPanel1Layout.createSequentialGroup()
                            .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                .addComponent(homeAddrLabel)
                                .addComponent(studentEmailLabel)
                                .addComponent(parentEmailLabel))
                            .addGap(39, 39, 39)
                            .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                .addComponent(studentEmailField, javax.swing.GroupLayout.Alignment.TRAILING)
                                .addComponent(homeAddrField)
                                .addComponent(parentEmailField)))))
                .addContainerGap(132, Short.MAX_VALUE))
        );
        jPanel1Layout.setVerticalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(nameLabel)
                    .addComponent(nameField, javax.swing.GroupLayout.PREFERRED_SIZE, 29, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(fnameField, javax.swing.GroupLayout.PREFERRED_SIZE, 29, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(fnameLabel))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(mnameField, javax.swing.GroupLayout.PREFERRED_SIZE, 29, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(mnameLabel))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(birthdateField, javax.swing.GroupLayout.PREFERRED_SIZE, 29, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(birthdateLabel))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(phoneField, javax.swing.GroupLayout.PREFERRED_SIZE, 29, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(phoneLabel))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(hphoneLabel)
                    .addComponent(hphoneField, javax.swing.GroupLayout.PREFERRED_SIZE, 29, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(homeAddrField, javax.swing.GroupLayout.PREFERRED_SIZE, 29, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(homeAddrLabel))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(studentEmailField, javax.swing.GroupLayout.PREFERRED_SIZE, 29, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(studentEmailLabel))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(parentEmailLabel)
                    .addComponent(parentEmailField, javax.swing.GroupLayout.PREFERRED_SIZE, 29, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(18, 18, 18)
                .addComponent(addButton, javax.swing.GroupLayout.DEFAULT_SIZE, 35, Short.MAX_VALUE)
                .addContainerGap())
        );

        javax.swing.GroupLayout jFrame1Layout = new javax.swing.GroupLayout(jFrame1.getContentPane());
        jFrame1.getContentPane().setLayout(jFrame1Layout);
        jFrame1Layout.setHorizontalGroup(
            jFrame1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jFrame1Layout.createSequentialGroup()
                .addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addContainerGap())
        );
        jFrame1Layout.setVerticalGroup(
            jFrame1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jFrame1Layout.createSequentialGroup()
                .addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addGap(0, 0, Short.MAX_VALUE))
        );

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
        setTitle("FPlaton");
        setBounds(new java.awt.Rectangle(300, 200, 0, 0));

        addStudentButton.setText("Προσθήκη Μαθητή");
        addStudentButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                addStudentButtonActionPerformed(evt);
            }
        });

        jLabel1.setText("fplaton - 2013");

        oikonomikaButton.setText("Οικονομικά");
        oikonomikaButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                oikonomikaButtonActionPerformed(evt);
            }
        });

        courseButton.setText("Προσθήκη Μαθήματος");
        courseButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                courseButtonActionPerformed(evt);
            }
        });

        OpenInsertClassFormjButton.setText("Προσθήκη Τμήματος");
        OpenInsertClassFormjButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                OpenInsertClassFormjButtonActionPerformed(evt);
            }
        });

        viewStudentsButton.setText("Προβολή Μαθητών");
        viewStudentsButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                viewStudentsButtonActionPerformed(evt);
            }
        });

        addTeacherButton.setText("Προσθήκη Καθηγητή");
        addTeacherButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                addTeacherButtonActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                        .addComponent(jSeparator, javax.swing.GroupLayout.PREFERRED_SIZE, 453, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addContainerGap())
                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                        .addComponent(jLabel1)
                        .addGap(26, 26, 26))))
            .addGroup(layout.createSequentialGroup()
                .addGap(24, 24, 24)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                    .addComponent(addStudentButton, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(viewStudentsButton, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                    .addComponent(courseButton, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(addTeacherButton, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(oikonomikaButton, javax.swing.GroupLayout.PREFERRED_SIZE, 140, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(OpenInsertClassFormjButton))
                .addGap(0, 0, Short.MAX_VALUE))
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addGap(17, 17, 17)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                        .addComponent(addStudentButton, javax.swing.GroupLayout.PREFERRED_SIZE, 67, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addComponent(courseButton, javax.swing.GroupLayout.PREFERRED_SIZE, 52, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addComponent(OpenInsertClassFormjButton, javax.swing.GroupLayout.PREFERRED_SIZE, 67, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(49, 49, 49)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                    .addComponent(oikonomikaButton, javax.swing.GroupLayout.DEFAULT_SIZE, 67, Short.MAX_VALUE)
                    .addComponent(viewStudentsButton, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(addTeacherButton, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 71, Short.MAX_VALUE)
                .addComponent(jSeparator, javax.swing.GroupLayout.PREFERRED_SIZE, 10, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(3, 3, 3)
                .addComponent(jLabel1)
                .addContainerGap())
        );

        layout.linkSize(javax.swing.SwingConstants.VERTICAL, new java.awt.Component[] {courseButton, oikonomikaButton});

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void addStudentButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_addStudentButtonActionPerformed
        jFrame1.setVisible(rootPaneCheckingEnabled); // show internal frame
    }//GEN-LAST:event_addStudentButtonActionPerformed

    private void nameFieldActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_nameFieldActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_nameFieldActionPerformed

    private void addButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_addButtonActionPerformed

        String name = null, fatherName = null, motherName = null, email = null,
                birthdate = null, homeAddr = null, studentEmail = null,
                parentEmail = null, homePhone = null, personalPhone = null;
        boolean verify = true;

        ArrayList<String> err = new ArrayList<>();

        // Validate fields
        if (!isNullorEmpty(nameField.getText())) {
            name = nameField.getText();
        } else {
            verify = false;
            err.add("Please add a correct Name");
        }

        if (!isNullorEmpty(fnameField.getText())) {
            fatherName = fnameField.getText();
        } else {
            verify = false;
            err.add("Please add a correct Father's name");
        }

        if (!isNullorEmpty(mnameField.getText())) {
            motherName = mnameField.getText();
        } else {
            verify = false;
            err.add("Please add a correct Mother's name");
        }

        if (!isNullorEmpty(homeAddrField.getText())) {
            homeAddr = homeAddrField.getText();
        } else {
            verify = false;
            err.add("Please add a correct Home address");
        }
        // TODO: add a better field for birthday
        if (!isNullorEmpty(birthdateField.getText())) {
            birthdate = birthdateField.getText();
        } else {
            verify = false;
            err.add("Please add a correct Birthdate");
        }

        if (isEmail(studentEmailField.getText())) {
            studentEmail = studentEmailField.getText();
        } else {
            verify = false;
            err.add("Please add a correct student's email");
        }

        if (isEmail(parentEmailField.getText())) {
            parentEmail = parentEmailField.getText();
        } else {
            verify = false;
            err.add("Please add a correct parent's email");
        }

        if (!isNullorEmpty(phoneField.getText())) {
            personalPhone = phoneField.getText();
        } else {
            verify = false;
            err.add("Please add a correct personal phone");
        }

        if (!isNullorEmpty(hphoneField.getText())) {
            homePhone = hphoneField.getText();
        } else {
            verify = false;
            err.add("Please add a correct home phone number");
        }

        if (verify == true) {
            try {
                SQLiteJDBC connection = new SQLiteJDBC("frontistirio.db");
                boolean check = true;
                String create_table = "CREATE TABLE IF NOT EXISTS STUDENTS "
                        + "(ID INTEGER PRIMARY KEY  AUTOINCREMENT,"
                        + " NAME          TEXT    NOT NULL,"
                        + " FATHERNAME    TEXT    NOT NULL,"
                        + " MOTHERNAME    TEXT    NOT NULL,"
                        + " STUDENTEMAIL  TEXT    NOT NULL,"
                        + " PARENTEMAIL   TEXT    NOT NULL,"
                        + " BIRTHDATE     CHAR(50) NOT NULL,"
                        + " HOMEADDRESS   CHAR(50) NOT NULL,"
                        + " HOMEPHONE     CHAR(50) NOT NULL,"
                        + " PERSONALPHONE CHAR(50) NOT NULL)";
                connection.execute(create_table); // create db table
                ResultSet rs = connection.executeQuery("select * from students");
                while (rs.next()) {
                    // check if name exist and if father's name is the same
                    if (rs.getString("name").equals(name)
                            && rs.getString("fathername").equals(fatherName)) {
                        JOptionPane.showMessageDialog(jFrame1,
                                "Ο μαθητής υπάρχει.\n Ελένξτε τα στοιχεία");
                        check = false;
                    } else if (rs.getString("STUDENTEMAIL").equals(studentEmail)
                            || rs.getString("PARENTEMAIL").equals(parentEmail)) {
                        JOptionPane.showMessageDialog(jFrame1,
                                "Το email αυτό υπάρχει.\n Ελένξτε τα στοιχεία");
                        check = false;
                    }
                }
                if (check == true) {
                    // Add to database (INSERT query with formatted strings)
                    PreparedStatement prep = connection.conn.prepareStatement(
                            "INSERT INTO STUDENTS VALUES(?,?, ?, ?, ?, ?, ?, ?, ? ,?);");
                    prep.setString(2, name);
                    prep.setString(3, fatherName);
                    prep.setString(4, motherName);
                    prep.setString(5, studentEmail);
                    prep.setString(6, parentEmail);
                    prep.setString(7, birthdate);
                    prep.setString(8, homeAddr);
                    prep.setString(9, homePhone);
                    prep.setString(10, personalPhone);
                    connection.conn.setAutoCommit(false);
                    prep.execute();
                    connection.conn.setAutoCommit(true);
                }
            } catch (SQLException ex) {
                Logger.getLogger(CentralForm.class.getName()).log(Level.SEVERE, null, ex);
            }
        } else {
            // TODO improve this ugly thing
            JOptionPane.showMessageDialog(jFrame1, err);
        }
    }//GEN-LAST:event_addButtonActionPerformed

    private void parentEmailFieldActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_parentEmailFieldActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_parentEmailFieldActionPerformed

    private void oikonomikaButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_oikonomikaButtonActionPerformed

        oikonomiko ecoForm = new oikonomiko();
        ecoForm.setVisible(true);

    }//GEN-LAST:event_oikonomikaButtonActionPerformed

    private void courseButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_courseButtonActionPerformed
        new Course().setVisible(true);
    }//GEN-LAST:event_courseButtonActionPerformed

    private void OpenInsertClassFormjButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_OpenInsertClassFormjButtonActionPerformed
        EditClassForm EditClass = new EditClassForm();
        EditClass.setVisible(true);
    }//GEN-LAST:event_OpenInsertClassFormjButtonActionPerformed

    private void viewStudentsButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_viewStudentsButtonActionPerformed
       ViewStudents viewStudentForm = new ViewStudents();
       viewStudentForm.setVisible(true);
    }//GEN-LAST:event_viewStudentsButtonActionPerformed

    private void addTeacherButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_addTeacherButtonActionPerformed
        // TODO add your handling code here:
        addteacher newTeacher =new addteacher();
        newTeacher.setVisible(true);
    }//GEN-LAST:event_addTeacherButtonActionPerformed

    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton OpenInsertClassFormjButton;
    private javax.swing.JButton addButton;
    private javax.swing.JButton addStudentButton;
    private javax.swing.JButton addTeacherButton;
    private javax.swing.JTextField birthdateField;
    private javax.swing.JLabel birthdateLabel;
    private javax.swing.JButton courseButton;
    private javax.swing.JTextField fnameField;
    private javax.swing.JLabel fnameLabel;
    private javax.swing.JTextField homeAddrField;
    private javax.swing.JLabel homeAddrLabel;
    private javax.swing.JTextField hphoneField;
    private javax.swing.JLabel hphoneLabel;
    private javax.swing.JFrame jFrame1;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JPanel jPanel1;
    private javax.swing.JSeparator jSeparator;
    private javax.swing.JTextField mnameField;
    private javax.swing.JLabel mnameLabel;
    private javax.swing.JTextField nameField;
    private javax.swing.JLabel nameLabel;
    private javax.swing.JButton oikonomikaButton;
    private javax.swing.JTextField parentEmailField;
    private javax.swing.JLabel parentEmailLabel;
    private javax.swing.JTextField phoneField;
    private javax.swing.JLabel phoneLabel;
    private javax.swing.JTextField studentEmailField;
    private javax.swing.JLabel studentEmailLabel;
    private javax.swing.JButton viewStudentsButton;
    // End of variables declaration//GEN-END:variables
}
